home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / smailsrc.zip / SMAIL.ZIP / MAP.C < prev    next >
Text File  |  1990-05-05  |  2KB  |  79 lines

  1. /*
  2. **    Patched for MS-DOS compatibility by Stephen Trier March, April and
  3. **    May, 1990.  This file is in the public domain.
  4. */
  5.  
  6. #ifndef lint
  7. static char     *sccsid="@(#)map.c    2.5 (smail) 9/15/87";
  8. #endif
  9.  
  10. # include    <stdio.h>
  11. # include    <sys/types.h>
  12. # include    "defs.h"
  13.  
  14. extern int queuecost;
  15. #ifdef MSDOS
  16. extern enum erouting routing, routelevel;  /* Use to check on rerouting */
  17. #endif
  18.  
  19. /*
  20. **
  21. **  map(): map addresses into <host, user, form, cost> sets.
  22. **
  23. **  Calls resolve() for each address of argv.  The result is hostv and 
  24. **  userv arrays (pointing into buffers userz and hostz), and formv array.
  25. **
  26. */
  27.  
  28. map(argc, argv, hostv, userv, formv, costv)
  29. int argc;                /* address count         */
  30. char **argv;                /* address vector         */
  31. char *hostv[];                /* remote host vector         */
  32. char *userv[];                /* user name vector         */
  33. enum eform formv[];            /* address format vector     */
  34. int costv[];                /* cost vector             */
  35. {
  36.     int i, cost;
  37.     enum eform resolve();
  38.     char *c;
  39.     static char userbuf[BIGBUF], *userz;
  40.     static char hostbuf[BIGBUF], *hostz;
  41.  
  42.     userz = userbuf;
  43.     hostz = hostbuf;
  44.  
  45.     for( i=0; i<argc; i++ ) {
  46. #ifdef MSDOS
  47.         /*
  48.          *   We only want to do routing if this is the first pass
  49.          *   or the message has not gotten through yet.
  50.          */
  51.  
  52.         if ((routing == routelevel) || (formv[i] != SENT))  {
  53. #endif /* MSDOS */
  54. #ifdef DEFQUEUE
  55.         cost = queuecost+1;        /* default is queueing */
  56. #else
  57.         cost = queuecost-1;        /* default is no queueing */
  58. #endif
  59.         userv[i] = userz;        /* put results here */
  60.         hostv[i] = hostz;
  61.         if ( **argv == '(' ) {        /* strip () */
  62.             ++*argv;
  63.             c = index( *argv, ')' );
  64.             if (c)
  65.                 *c = '\0';
  66.         }
  67.                         /* here it comes! */
  68.         formv[i] = resolve(*argv++, hostz, userz, &cost);
  69.         costv[i] = cost;
  70.         userz += strlen( userz ) + 1;    /* skip past \0 */
  71.         hostz += strlen( hostz ) + 1;
  72. #ifdef MSDOS
  73.         } else {
  74.         argv++;
  75.         }
  76. #endif
  77.     }
  78. }
  79.